﻿CREATE PROCEDURE [dbo].[proc_Order_Change_OrderItem_Getlist]
	(
		@Id int,
		@OId uniqueidentifier
	)
AS
	Select
		Id
		,OId
		,ProductId
		,ProductName
		,UnitPrice
		,Quantity
		,Salesman
		,SalesmanAccount
		,DepId
		,CompanyId
		,CreateDate
		,DESCRIPTION
		,0 As Change
	From Order_Item Where OId=@OId
Union All
	Select
		Id
		,OId
		,ProductId
		,ProductName
		,UnitPrice
		,Quantity
		,Salesman
		,SalesmanAccount
		,DepId
		,CompanyId
		,CreateDate
		,DESCRIPTION
		,1 As Change
	From Order_Change_Item Where CId=@Id And OId=@OId
Order by ProductId,Change
RETURN
